//
//  BaseEmptyDataView.m
//  DingDongXiChe
//
//  Created by wtjr on 2018/1/3.
//  Copyright © 2018年 xieyingze. All rights reserved.
//

#import "BaseEmptyDataView.h"
#import "BaseImageView.h"
#import "AppHeader.h"


@interface BaseEmptyDataView()

@property (nonatomic, strong) UIView *mainView;

@end

@implementation BaseEmptyDataView

- (instancetype)init {
    self = [super init];
    if (self) {
        [self initSubViews];
        [self autoLayoutForSubViews];
    }
    return self;
}

#pragma mark - BaseMethod

- (void)initSubViews {
    [self addSubview:self.mainView];
}

- (void)autoLayoutForSubViews {
    [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@0);
    }];
}

#pragma mark - Interface


#pragma mark - Delegate


#pragma mark - TouchEvent


#pragma mark - Setter


#pragma mark - Getter

- (UIView *)mainView {
    if (!_mainView) {
        _mainView = [UIView new];
        
        //提示图片
        BaseImageView *emptyImagView = [BaseImageView new];
        emptyImagView.imageName = @"wd_unity_emptyData";
        [_mainView addSubview:emptyImagView];
        [emptyImagView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(@0);
            make.centerY.equalTo(@-60.f);
            make.width.height.equalTo(@(60 * kUI_Percent));
        }];
        
        //提示文字
        BaseLabel *emptyDataLabel = [BaseLabel new];
        [emptyDataLabel setLabelStyle:@"暂无数据|点击刷新" textColor:KCOLOR_font_tint textFont:kFONT_HelLight(12.f) texrAlignment:NSTextAlignmentCenter];
        [_mainView addSubview:emptyDataLabel];
        [emptyDataLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(emptyImagView.mas_bottom).offset(10);
            make.centerX.equalTo(emptyImagView);
            make.size.mas_equalTo(CGSizeMake(300, 30));
        }];
        //添加手势
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(reloadEmptyData)];
        [_mainView addGestureRecognizer:tap];
    }
    return _mainView;
}

@end
